﻿using Li.EntityFramework.IAppService;
using Li.EntityFramework.IRepository;
using Li.EntityFramework.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Li.EntityFramework.AppService
{
    public class UserAppServcie :BaseAppService<User>,IUserAppService
    {
        private IUserRepository _userRepository;
        IArticleRepository _articleRepository;
        public UserAppServcie(IUserRepository userRepository,IArticleRepository articleRepository)
        {
            _userRepository = userRepository;
            _articleRepository = articleRepository;
        }
        public IEnumerable<dynamic> GetUserArticle()
        {
            var query = from a in _userRepository.GetALL()
                        join b in _articleRepository.GetALL()
                        on a.ID equals b.UserID
                        select new
                        {
                            a.Name,
                            a.Sex,
                            b.Title,
                            b.Text
                        };
            return query.ToList();
        }
    }
}
